<?php
/* @var $this UserController */
/* @var $model User */
/* @var $form CActiveForm */
?>

<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/seajs/sea-debug.js" data-main='./js/init/register'></script>
<h3>新用户注册,你懂的!</h3>
<div class="row show-grid" style="margin-top: 15px;">

    <div class="span5 form">

        <?php $form = $this->beginWidget('CActiveForm', array(
        'id' => 'user-register-form',
        'enableAjaxValidation' => false,
    )); ?>

        <p class="note">标有 <span class="required">*</span> 的项是必填的!</p>

        <div class="row">
            <label for="name">用户名</label>
            <input type="text" name="name" id="name" class="{required:true,messages:{required:'用户名必须要填写',remote:'这个名字已经被抢了'}}" value="ktgu">
        </div>

        <div class="row">
            <label for="email">邮箱</label>
            <input type="text" name="email" id="email" class="{required:true,email:true,messages:{required:'邮箱必须要填写',remote:'这个邮箱已经被注册了'}}" value="29283212@qq.com">
        </div>

        <div class="row">
            <label for="password">设置您的密码</label>
            <input type="password" name="password" id="password" class="{required:true,messages:{required:'密码必须要填写'}}" value="a">
        </div>

        <div class="row">
            <label for="confirm">请再输入一次密码</label>
            <input type="password" name="confirm" id="confirm" class="{required:true, equalTo:'#password',messages:{required:'确认密码必须要填写',equalTo:'两次输入的密码不符'}}" value="a">
        </div>

        <div class="row">
            <label for="captcha">验证码</label>
            <input type="text" name="verifyCode" id="verifyCode" class="span1 {required:true}" maxlength="8" value="1234">
            <?php
            $this->widget('CCaptcha', array(
                'showRefreshButton' => true,
                'buttonLabel' => '看不清,换一张',
                'clickableImage' => true,
                'imageOptions' => array('alt' => '点击换图', 'title' => '点击换图', 'style' => 'height:28px; cursor:pointer'),
            ));
            ?>

            <?php
            if (array_key_exists('verifyCode', $model->getErrors())) {
                echo '<span class="error">验证码不正确</span>';
            }
            ?>
        </div>

        <div class="row">
            <label>
                <input type="checkbox" name="accept" id="accept" checked="checked" class="{required:true}"> 我接受 <a href="#">用户协议</a>
            </label>
        </div>

        <div class="row buttons">
            <?php
            $this->widget('bootstrap.widgets.TbButton', array(
                'buttonType' => 'submit',
                'type' => 'primary',
                'label' => '立即注册',
                'loadingText' => '正在注册...',
                'htmlOptions' => array('id' => 'btnSubmit', 'data-toggle' => 'button-stateful'),
            ));
            ?>

            <?php
            $this->widget('bootstrap.widgets.TbButton', array(
                'label' => '取消',
                'htmlOptions' => array('id' => 'btnCancel'),
            ));
            ?>
        </div>

        <?php $this->endWidget(); ?>

        <!--
        TODO:
        1. 控制验证码的宽高
        2. 控制验证码的字数
        3. 修改验证码后面的提示,改为:看不清,换一个
        4. 理解客户端验证,以及Controller里面的rules
        -->

    </div>
    <!-- //form -->
    <div class="span6">
        注册过? <a href="?r=site/login">点此登陆</a>


        <div>
            <h3>使用合作网站帐号登录</h3>

            <div class="connections">
                <a href="#" class="btn-connect btn-weibo"></a>
                <a href="#" class="btn-connect btn-qq"></a>
                <a href="#" class="btn-connect btn-douban"></a>
                <a href="#" class="btn-connect btn-taobao"></a>
                <a href="#" class="btn-connect btn-renren"></a>
            </div>
        </div>

    </div>
</div>
